package com.binance.mbxgateway.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.binance.master.models.APIRequest;
import com.binance.master.models.APIRequest.VoidBody;
import com.binance.master.models.APIResponse;
import com.binance.master.utils.WebUtils;
import com.binance.mbxgateway.api.InfoApi;
import com.binance.mbxgateway.vo.request.info.GetUserUrlReqeust;
import com.binance.mbxgateway.web.service.IInfoService;

@RestController
public class InfoController implements InfoApi {

    @Autowired
    private IInfoService infoService;

    @Override
    public APIResponse<String> getWssUrl(@RequestBody APIRequest<VoidBody> request) {
        return APIResponse.getOKJsonResult(this.infoService.getWssUrl(WebUtils.getHttpServletRequest()));
    }

    @Override
    public APIResponse<String> getKlineUrl(@RequestBody APIRequest<VoidBody> request) {
        return APIResponse.getOKJsonResult(this.infoService.getKlineUrl(WebUtils.getHttpServletRequest()));
    }

    @Override
    public APIResponse<String> getMktdataWssUrl(@RequestBody APIRequest<VoidBody> request) {
        return APIResponse.getOKJsonResult(this.infoService.getMktdataWssUrl(WebUtils.getHttpServletRequest()));
    }

    @Override
    public APIResponse<Long> getServerTime(@RequestBody APIRequest<VoidBody> request) {
        return APIResponse.getOKJsonResult(this.infoService.getServerTime());
    }

    @Override
    public APIResponse<Boolean> getBranding(@RequestBody APIRequest<VoidBody> request) {
        return APIResponse.getOKJsonResult(this.infoService.getBranding());
    }

    @Override
    public APIResponse<String> getUserUrl(@RequestBody @Validated APIRequest<GetUserUrlReqeust> request) {
        return APIResponse.getOKJsonResult(this.infoService.getUserUrl(request.getBody()));
    }

    @Override
    public APIResponse<String> getDepthUrl(@RequestBody APIRequest<VoidBody> request) {
        return APIResponse.getOKJsonResult(this.infoService.getDepthUrl());
    }

}
